/**
 * 任务测试
 */
Ext.define('Module.test.TestJcBz', {
	extend : 'Ext.panel.Panel',
	layout: 'border',
	initComponent : function() {
		var me = this;
		var jcBz = me.jcBz = Ext.create('Ext.panel.Panel',{
			title: '任务测试',
			region: 'center',
			padding: '0 1 0 0',
			height:500,
			items: [{
				xtype: 'form',
				bodyPadding: 20,
				defaults: {columnWidth: 1,labelWidth: 65,width:335,padding: '5 30 5 10'},
				items: [/*{
					xtype:'datefield',
					labelWidth: 65,
					allowBlank: false,
					id:me.id+'-starttime',
					format:'Y-m-d',
					fieldLabel: '开始时间',
					listeners: {
						change:function(t, item, eOpts ){
							var endtime=null;
							if(Ext.getCmp(me.id+'-endtime').getValue() !=null){ 
								endtime=Ext.getCmp(me.id+'-endtime').getValue();
							}
							Ext.getCmp(me.id+'rw-id').getStore().load({
				        		params:{
				        			starttime : Ext.getCmp(me.id+'-starttime').getValue(),
				        			endtime : endtime
				        		},
				        		callback: function(records, options, success){
				    				if(records.length == 0){
				    					Ext.getCmp(me.id+'rw-id').setRawValue('无数据');
				    					Ext.getCmp(me.id+'rw-id').setReadOnly(true);
				    					Ext.getCmp(me.id+'rw-id').setFieldStyle({
				    						color: "red"
				    					});
				    				}else{
										Ext.getCmp(me.id+'rw-id').setRawValue("");
										Ext.getCmp(me.id+'rw-id').setReadOnly(false);
										Ext.getCmp(me.id+'rw-id').setFieldStyle({
											color: "#000000"
								        });
    									}
			    				}
				        	});
						}
					}
				},*/{
					xtype:'datefield',
					labelWidth: 65,
					allowBlank: false,
					fieldLabel: '结束时间',
					id:me.id+'-endtime',
					format:'Y-m-d',
					listeners: {
						change:function(t, item, eOpts ){
							Ext.getCmp(me.id+'rw-id').getStore().load({
				        		params:{
				        			date : item,
				        		},
				        		callback: function(records, options, success){
				    				if(records.length == 0){
				    					Ext.getCmp(me.id+'rw-id').setRawValue('无数据');
				    					Ext.getCmp(me.id+'rw-id').setReadOnly(true);
				    					Ext.getCmp(me.id+'rw-id').setFieldStyle({
				    						color: "red"
				    					});
				    				}else{
										Ext.getCmp(me.id+'rw-id').setRawValue("");
										Ext.getCmp(me.id+'rw-id').setReadOnly(false);
										Ext.getCmp(me.id+'rw-id').setFieldStyle({
											color: "#000000"
								        });
    									}
			    				}
				        	});
						}
					}
				},{
					xtype:'combo',
					fieldLabel: '任务',
					displayField: 'title',
				    valueField: 'bzid',
				    queryMode: 'local',
				    id:me.id+'rw-id',
				    editable:false,
					allowBlank: false,
				    store: Ext.create('Ext.data.Store',{
						autoLoad: true,
						fields: ['id','bzid','title'],
				        proxy: {
				            type: 'ajax',
				            url: 'tsk/rw.do'
				        }
					}),
					listeners: {
						select:function( combo, records, eOpts ){
				        	Ext.getCmp(me.id+'bzjs-id').getStore().load({
				        		params:{
				        			bzid : records[0].get('bzid')
				        		},
				        		callback: function(records, options, success){
				    				if(records.length == 0){
				    					Ext.getCmp(me.id+'bzjs-id').setRawValue('无数据');
				    					Ext.getCmp(me.id+'bzjs-id').setReadOnly(true);
				    					Ext.getCmp(me.id+'bzjs-id').setFieldStyle({
				    						color: "red"
				    					});
				    				}else{
										Ext.getCmp(me.id+'bzjs-id').setRawValue("");
										Ext.getCmp(me.id+'bzjs-id').setReadOnly(false);
										Ext.getCmp(me.id+'bzjs-id').setFieldStyle({
											color: "#000000"
								        });
    									}
			    				}
				        	});
				        	
				        }
					}
				},{
					xtype:'combo',
					fieldLabel: '角色',
					displayField: 'name',
				    valueField: 'id',
				    queryMode: 'local',
				    editable:false,
				    id:me.id+'bzjs-id',
					allowBlank: false,
				    store: Ext.create('Ext.data.Store',{
						autoLoad: false,
						fields: ['id','name','jsid'],
				        proxy: {
				            type: 'ajax',
				            url: 'tsk/js.do'
				        }
					}),
					listeners: {
						select:function( combo, records, eOpts ){
				        	Ext.getCmp(me.id+'bzzyZygc-id').getStore().load({
				        		params:{
				        			jsid : records[0].get('id')
				        		},
				        		callback: function(records, options, success){
				    				if(records.length == 0){
				    					Ext.getCmp(me.id+'bzzyZygc-id').setRawValue('无数据');
				    					Ext.getCmp(me.id+'bzzyZygc-id').setReadOnly(true);
				    					Ext.getCmp(me.id+'bzzyZygc-id').setFieldStyle({
				    						color: "red"
				    					});
				    				}else{
										Ext.getCmp(me.id+'bzzyZygc-id').setRawValue("");
										Ext.getCmp(me.id+'bzzyZygc-id').setReadOnly(false);
										Ext.getCmp(me.id+'bzzyZygc-id').setFieldStyle({
											color: "#000000"
								        });
    									}
			    				}
				        	});
				        	
				        }
					}
				},{
					xtype:'combo',
					fieldLabel: '作业过程',
					displayField: 'name',
				    valueField: 'id',
				    queryMode: 'local',
				    id:me.id+'bzzyZygc-id',
				    editable:false,
					allowBlank: false,
				    store: Ext.create('Ext.data.Store',{
						autoLoad: false,
						fields: ['id','name'],
				        proxy: {
				            type: 'ajax',
				            url: 'tsk/gc.do'
				        }
					})
				}]
			}]
			
		});
		
		
		me.items = [jcBz];
		
		me.callParent();
	}
});